package blogger.client.ui.panels;


import blogger.client.ui.utils.SlideTimer;
import blogger.client.ui.utils.Working;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;

public class SlidePanel extends VerticalPanel {
    protected Working working = new Working(false);
    protected SlideTimer timer = null;
    protected PushButton closeButton = null;

    public SlidePanel(boolean forward) {
        timer = new SlideTimer(this, working, forward);

        closeButton = new PushButton(new Image("../images/minimize.gif"));
        closeButton.setStyleName("closeButton");
        closeButton.setSize("12px","12px");
        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                SlidePanel.this.pack();
            }
        });
        this.add(closeButton);

    }

    public SlidePanel() {
    }

    public Working getWorking() {
        return working;
    }

    public SlideTimer getTimer() {
        return timer;
    }

    public void pack() {
        if (!working.is()) {
            timer.scheduleRepeating(7);
        }
    }
    public void showElements(boolean bool) {
        WidgetCollection widgetCollection = this.getChildren();
        for(Widget w : widgetCollection)
            w.setVisible(bool);

    }
}
